package com.hxkj.client.service;

import com.hxkj.domain.po.AuthUser;
import com.hxkj.domain.po.FunctionMenu;
import com.hxkj.domain.po.FunctionSite;
import com.hxkj.token.po.LoginToken;
import com.platform.common.domain.result.ResultDataStruct;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
import java.util.Set;

/**
 * 用户服务API
 * <p>
 * Created by chenwei on 2018/5/15.
 */
@FeignClient(name = "cms-management")
@Service
public interface UserServiceClient {


    /**
     * 登录
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/login", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    ResultDataStruct<LoginToken> login(@RequestBody AuthUser authUser) throws Exception;


    /**
     * 获取单个用户信息
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/account/get", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    ResultDataStruct<AuthUser> getUser(@RequestBody String account) throws Exception;


    /**
     * 根据账户名查找角色
     *
     * @param account
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/role/get", consumes = "application/json;charset=UTF-8")
    ResultDataStruct<Set<String>> findRolesByAccount(@RequestBody String account) throws Exception;


    /**
     * 根据账户名查询权限
     *
     * @param account
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/permissions/get", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    ResultDataStruct<Set<String>> findPermissionsByAccount(@RequestBody String account) throws Exception;


    /**
     * 通过账户查询菜单
     *
     * @param functionSite
     * @return
     */
    @RequestMapping(value = "/user/menu/get", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    ResultDataStruct<List<FunctionMenu>> findFunctionMenuByAccount(@RequestBody FunctionSite functionSite) throws Exception;


    /**
     * 通过token获取用户信息成功
     *
     * @param accessToken
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/token/id", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    ResultDataStruct<AuthUser> getUserInfoByToken(@RequestBody String accessToken) throws Exception;


    /**
     * 通过id获取用户信息
     *
     * @param userId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/id/get", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    ResultDataStruct<AuthUser> getUserInfoById(@RequestBody String userId) throws Exception;
}
